--[[/**
 * 每存在一个生命低于生命1/生命2/生命3的敌人, 艾达属性提高 属性值1/属性值2/属性值3
 * [生命1,生命2,生命3,属性1,属性值1,属性值2,属性值3,属性2,属性值1,属性值2,属性值3]
-- *
-- */]]

---@class BuffEffect445100 : BaseBuffEffect
BuffEffect445100 = ClientFight.CreateClass("BuffEffect445100", ClientFight.BaseBuffEffect)
local t = BuffEffect445100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local team = fight.teams[3 - buff.target.teamIndex];
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local attrSize = (table.getn(buffEffectValue) - 3) / 4;
    buff.attributes.attributes = {};
    for k, enemy in pairs(team.fighters) do
        local hp = enemy.hp;
        local v = hp / FighterAttributeManager.getFightAttr(enemy, FighterAttributeEnum.HP) * 10000;
        local index = 0;
        if (enemy:isSummons()) then
            goto continue;
        end
        if (enemy:isDie()) then
            goto continue;
        end
        if (v < buffEffectValue[3]) then
            index = 2;
            SkillRoleMgr.savePathFile("[" + fight.frame + "][EFFECT]Fighter " + buff.target.fighterId + " Buff"
                    + buff.modelId + " 敌人血量低于：" + buffEffectValue[3] + " %%");
        elseif (v < buffEffectValue[2]) then
            index = 1;
            SkillRoleMgr.savePathFile("[" + fight.frame + "][EFFECT]Fighter " + buff.target.fighterId + " Buff"
                    + buff.modelId + " 敌人血量低于：" + buffEffectValue[2] + " %%");
        elseif (v < buffEffectValue[1]) then
            index = 0;
            SkillRoleMgr.savePathFile("[" + fight.frame + "][EFFECT]Fighter " + buff.target.fighterId + " Buff"
                    + buff.modelId + " 敌人血量低于：" + buffEffectValue[1] + " %%");
        else
            goto continue;
        end
        :: continue :: ;
    end
    for i = 0, attrSize do
        local attriBegin = 3 + i * 4;
        local attrType = buffEffectValue[attriBegin];
        local attrValue = buffEffectValue[attriBegin + 1 + index];
        buff.attributes:changeAttribute(attrType, attrValue);
    end
    ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

t.New()